package com.luoyi.util.ehr;

import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;
import cn.hutool.poi.excel.ExcelWriter;

import java.util.ArrayList;
import java.util.List;

public class ExcelContentIDobble {


    public static void main(String[] args) {
        // 读取excel文件并遍历Sheet1的行，复制每一行内容并新增一行在其下方
        ExcelReader reader = ExcelUtil.getReader("D:\\fileTest\\test4.xlsx");
        reader.setSheet("Sheet1");
        List<List<Object>> read = reader.read();
        for (List<Object> objects : read) {
            System.out.println(objects);
        }
        reader.close();
        List<List<Object>> newList = new ArrayList<>();
        for (int i = 0; i < read.size(); i++) {
            newList.add(read.get(i));
            newList.add(read.get(i));
        }

        ExcelWriter writer = ExcelUtil.getWriter("D:\\fileTest\\test4.xlsx");
        writer.setSheet("Sheet2");
        writer.write(newList);
        writer.flush();
        writer.close();
    }
}
